//获取时间
export const getDay = (day, start, end) => {
    const today = new Date();
    const targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
    today.setTime(targetday_milliseconds);
    const tYear = today.getFullYear();
    let tMonth = today.getMonth();
    let tDate = today.getDate();
    tMonth = doHandleMonth(tMonth + 1);
    tDate = doHandleMonth(tDate);
    return start
        ? tYear + '-' + tMonth + '-' + tDate + ' ' + '00:00:00'
        : end
        ? tYear + '-' + tMonth + '-' + tDate + ' ' + '23:59:59'
        : tYear + '-' + tMonth + '-' + tDate;
};
const doHandleMonth = month => {
    let m = month;
    if (month.toString().length == 1) {
        m = '0' + month;
    }
    return m;
};
// 近N月
export const getRecentMonth = n => {
    let result = '';
    const datenow = new Date();
    datenow.setMonth(datenow.getMonth() - n);
    const dyear = datenow.getFullYear();
    let dmonth = datenow.getMonth() + 1;
    let dmonth2 = '';
    dmonth = dmonth < 10 ? 0 + dmonth : dmonth;
    const dday = datenow.getDate();
    let dday2 = '';
    if (dmonth.toString().length == 1) {
        dmonth2 = '0' + dmonth;
    } else {
        dmonth2 = dmonth.toString();
    }
    if (dday.toString().length == 1) {
        dday2 = '0' + dday;
    } else {
        dday2 = dday.toString();
    }
    const datestart = dyear.toString() + '-' + dmonth2 + '-' + dday2;
    result += datestart;
    return result;
};
